package com.xzy.sms.web.system.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xzyframework.persistence.BaseEntity;

/**
 * 用户组实体
 * 
 * @author macong
 * @since 1.0
 * @version 2014-10-16 macong
 */
@Entity
@Table(name = "pub_usergroup")
public class Usergroup extends BaseEntity {
    
    /** 序列化 */
    private static final long serialVersionUID = -2723410811307174650L;
    
    /** 用户组名称 */
    @Id
    @GeneratedValue(generator = "UIDGenerator")
    @GenericGenerator(name = "UIDGenerator", strategy = "com.xzyframework.persistence.UIDGenerator")
    @Column(length = 40)
    private String id;
    
    /** 用户组名称 */
    @NotBlank(message = "用户组名称不能为空")
    @NotNull(message = "用户组名称不能为空")
    @Size(min = 1, max = 40, message = "用户组名称字符长度必须在40个字符以内")
    private String name;
    
    /** 业务类型，1为用餐类型、2为用餐类型 */
    @NotNull(message = "业务类型不能为空")
    @NotBlank(message = "业务类型不能为空")
    @Length(min = 1, max = 1)
    protected String type;
    
    /** 备注信息 */
    @Column(length = 255)
    @Size(min = 0, max = 255, message = "备注长度必须在255个字符以内")
    private String remarks;
    
    /** 用户组关联用户集合 */
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "usergroup")
    private List<UsergroupUser> usergroupUsers;
    
    /** 权限关联用户组集合 */
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "usergroup")
    @JsonIgnore
    private List<PermUsergroup> permUsergroups;
    
    /**
     * 构造函数
     */
    public Usergroup() {
    }
    
    /**
     * 构造函数
     * 
     * @param id id
     */
    public Usergroup(String id) {
        this.id = id;
    }
    
    /**
     * @return permUsergroups
     */
    public List<PermUsergroup> getPermUsergroups() {
        return permUsergroups;
    }
    
    /**
     * @param permUsergroups 要设置的 permUsergroups
     */
    public void setPermUsergroups(List<PermUsergroup> permUsergroups) {
        this.permUsergroups = permUsergroups;
    }
    
    /**
     * @return name
     */
    public String getName() {
        return name;
    }
    
    /**
     * @param name 要设置的 name
     */
    public void setName(String name) {
        this.name = name;
    }
    
    /**
     * @return type
     */
    public String getType() {
        return type;
    }
    
    /**
     * @param type 要设置的 type
     */
    public void setType(String type) {
        this.type = type;
    }
    
    /**
     * @return remarks
     */
    public String getRemarks() {
        return remarks;
    }
    
    /**
     * @param remarks 要设置的 remarks
     */
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
    
    /**
     * @return usergroupUsers
     */
    public List<UsergroupUser> getUsergroupUsers() {
        return usergroupUsers;
    }
    
    /**
     * @param usergroupUsers 要设置的 usergroupUsers
     */
    public void setUsergroupUsers(List<UsergroupUser> usergroupUsers) {
        this.usergroupUsers = usergroupUsers;
    }
    
    /**
     * @return permissionUsergroups
     */
    public List<PermUsergroup> getPermissionUsergroups() {
        return permUsergroups;
    }
    
    /**
     * @param permissionUsergroups 要设置的 permissionUsergroups
     */
    public void setPermissionUsergroups(List<PermUsergroup> permissionUsergroups) {
        this.permUsergroups = permissionUsergroups;
    }
    
}
